package raf;

import java.io.IOException;
import java.io.RandomAccessFile;

public class RandomAccessFile1 {
	public static void main(String[] args) throws IOException {
		int data[] = {5, 2, 4, 9, 12, 25, 24, 8, 10, 8};
		int d;
		
		RandomAccessFile raf;
		
		try {
			raf = new RandomAccessFile("random.dat", "rw");
		}
		catch (Exception e) {
			System.out.print("Error!");
			return;
		}
		
		for(int i = 0; i < data.length; i++) {
			try {
				raf.writeInt(data[i]);
			}
			catch (Exception e) {
				System.out.print("Error2");
				return;
			}
			
			try {
				raf.seek(0);
				d = raf.readInt();
				System.out.println(d);
			}
			catch (Exception e) {
				System.out.print("Error3");
			}
		}
	}

}
